#ifndef FSTREAM_LOG_TEST_H
#define FSTREAM_LOG_TEST_H

#include <fstream>
#include <string>

#include "cppunit/TestCase.h"
#include "cppunit/extensions/HelperMacros.h"
#include "fstream_log.hpp"

using std::ifstream;
using std::string;
using bobs::services::file_path;
using bobs::services::fstream_log;

class fstream_log_test : public CppUnit::TestFixture
{
public:
  void setUp() {}

  void tearDown() {}
  
  void testWrite()
  {
    string file("test.txt");
    string msg("testing");

    file_path path(file);
    fstream_log log(path);
    log.write(msg);

    ifstream str(file.c_str());
    string line;
    if (str) {
      getline(str, line);
      CPPUNIT_ASSERT_EQUAL(msg, line);
    } else {
      CPPUNIT_FAIL("Could not open file " + file + "!");
    }
  }

  CPPUNIT_TEST_SUITE(fstream_log_test);
  CPPUNIT_TEST(testWrite);
  CPPUNIT_TEST_SUITE_END();
};

#endif
